package com.nameless.controller.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nameless.entity.CarType;
import com.nameless.service.CarTypeService;
import com.nameless.vo.CarTypeVo;
import com.nameless.vo.Result;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ：潘淼淼
 * @date ：Created in 2023/2/27 9:48
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@Api
@RequestMapping("/cars/carType")
public class CarTypeController {

    @Autowired
    private CarTypeService carTypeService;

    @PostMapping("/typeAll")
    public Result selectList(@RequestBody CarTypeVo carTypeVo) {
        return carTypeService.selectList(carTypeVo);
    }
    @GetMapping("/typeAlls")
    public Result selectList2() {
        return carTypeService.selectLis();
    }

    //    修改
    @PostMapping("/update")
    public Result update(@RequestBody CarType carType) {
        return carTypeService.updates(carType);
    }

    //    删除
    @PostMapping("/del")
    public Result del(Integer id) {
        return carTypeService.deleteById(id);
    }

    //    添加
    @PostMapping("/save")
    public Result save(@RequestBody CarType carType) {
        return carTypeService.addOne(carType);

    }
    @RequestMapping("/getTypeName/{carId}")
    public CarType getTypeName(@PathVariable Integer carId){
        CarType typeName = carTypeService.getTypeName(carId);
        return typeName;
    }
}